package cn.tedu.es.es;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    @Autowired
    private StudentRepository studentRepository;
    @Autowired
    private StudentSearcher studentSearcher;

    public void save(Student stu) {
        studentRepository.save(stu);
    }
    public void deleteById(Long id) {
        studentRepository.deleteById(id);
    }
    public Iterable<Student> findAll() {
        return studentRepository.findAll();
    }
    public List<Student> findByName(String name, Pageable pageable) {
        return studentRepository.findByName(name, pageable);
    }
    public List<Student> findByNameOrBirthDate(String name, String birthDate) {
        return studentRepository.findByNameOrBirthDate(name, birthDate);
    }
    public List<Student> findByBirthDate(String birthDate) {
        return studentSearcher.findByBirthDate(birthDate);
    }

    public List<Student> findByBirthDateBetween(String from, String to, Pageable pageable) {
        return studentSearcher.findByBirthDateBetween(from, to, pageable);
    }
}
